<template>
	<view class="all-main">
		<u-loading-page :loading="loadding" loading-mode="semicircle" loading-text="欢迎进入风动社区"></u-loading-page>
		<view v-if="!loadding" class="main">
			<view class="image-list">
				<u-swiper :list="list2" keyName="ad_image" height="560" indicator indicatorMode="line" :autoplay="true" circular @click="apply"></u-swiper>
			</view>
		</view>
	</view>
</template>

<script>
	var util = require('@/util/request5.js');
	export default {
		data() {
			return {
				loadding: true,
				list2: [],
				userinfo: {}
			}
		},
		onLoad() {
			this.userinfo = uni.getStorageSync('userinfo');
			this.getData()
		},
		methods: {
			// 申领机器
			apply(index) {
				uni.navigateTo({
					url: '/pages/version5/index/apply/detail?id=' + this.list2[index].id + '&name=' + this.list2[index].name
				})
			},
			// 获取产品
			async getData() {
				const {
					data: res
				} = await this.$myHttp5({
					url: 'v1/getProductList',
					header: {
						'token': this.userinfo.token
					}
				});
				this.loadding = false
				if (res.code == 1) {
					res.data.map(item => {
						item.ad_image = util.API_URL + item.ad_image
					})
					this.list2 = res.data
				}
			}
		}
	}
</script>

<style lang="scss" scoped>
	page {
		background-color: #f3f4f6;
	}

	.all-main {
		.main {
			padding: 30rpx;
			
			.form-main {
				width: 90%;
				padding: 30rpx;
				border-radius: 16rpx;
			}
		}
	}
</style>